package com.yunbiao.ybbusstopplate.ui.fragment;

import android.widget.TextView;

import com.yunbiao.ybbusstopplate.R;
import com.yunbiao.ybbusstopplate.base.BaseFragment;
import com.yunbiao.ybbusstopplate.refactoring.ui.yibin.ZHXPortAgreement;

import io.reactivex.functions.Consumer;

public class LogFragment extends BaseFragment {

    private TextView textView;

    @Override
    public int getViewId() {
        return R.layout.fragment_log;
    }

    @Override
    public void initData() {
        textView = requireView().findViewById(R.id.tv_message);

        ZHXPortAgreement.getInstance().setLogConsumer(new Consumer<String>() {
            @Override
            public void accept(String s) throws Exception {
                textView.post(() -> {
                    textView.append("\n");
                    textView.append(s);
                });
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ZHXPortAgreement.getInstance().setLogConsumer(null);
    }

    @Override
    public void initListener() {

    }
}
